﻿@model WebUI.Models.QizSession
@{ 
    var tm = new WebUI.Models.QizItem() { SortIdx = 1 };
    var exts = new string[] { ".png", ".jpg", ".jpeg", ".gif" };
}
@{
    string PostControllerName = ViewBag.ModiffyControllerName != null ? ViewBag.ModiffyControllerName : "Recuper";
    ViewBag.Index = 1;
    string recuperID = null;
    if (Request["RecuperID"] != null)
    {
        recuperID = Request["RecuperID"].ToString();
    }
    var PreviewOnly = ViewBag.ForceEdit != true && (Model.ID != "-1" || "True".Equals(Request["PreviewOnly"], StringComparison.CurrentCultureIgnoreCase));

    if (Request["IsDebug"] == "True")
    {
        PreviewOnly = false;
    }

    bool skipSub = true;
    skipSub = "True".Equals(Request["SkipSub"], StringComparison.CurrentCultureIgnoreCase);



}
@{
    TempData["FileExts"] = exts;
    TempData["PreviewOnly"] = PreviewOnly;
    TempData["skipSub"] = skipSub;
    TempData["OriQizSessionModel"] = Model;
    TempData["QuizIndex"] = 1;
}
<link type="text/css" rel="Stylesheet" href="@Url.Content("~/Content/QizSessionEdit.css")"/>
@if (PreviewOnly && !skipSub)
{
    @Html.Partial("QsdRenders/AnchorsList", Model)
}
@using (Html.BeginForm("QizSessionEdit", PostControllerName, null, FormMethod.Post, new { enctype = "multipart/form-data", id = "SessionForm" }))
{
    if (PreviewOnly && !skipSub)
    {
    <a name="Subject_@(Model.QizSubject.ID)" id="Subject_@(Model.QizSubject.ID)"></a>
    }
    <div>
        @Html.Hidden("RecuperID", Model.ID)
        @Html.Hidden("TokenID", (string)ViewBag.TokenID)
        @Html.Partial("QsdRenders/Header", Model)
        @Html.Partial("QsdRenders/MessageAndWarnning", Model)
        <fieldset style="padding: 16px;">
            @Html.HiddenFor(model => model.ID)
            @Html.HiddenFor(model => model.QizSubjectID)
            @Html.HiddenFor(model => model.PID)
            <table width="100%" class="norborder width normal-input">
                <tr>
                    <td colspan="2" valign="middle">
                        <ul class="qizdetails quizlv0">
                            <li class="quiz-group-title quiz-group-title" style="padding: 0px;">
                                <div class="not-null " style="vertical-align: middle;">
                                    <span>
                                        <img alt="检查时间(必须填写)" src="@Url.Content("~/Content/Images/checkClock.png")" style="padding: 0px;
                                            vertical-align: middle" /></span> *检查时间：
                                    @Html.EditorFor(model => model.Timemark, "DateTimeAndNull")
                                </div>
                            </li>
                        </ul>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        @Html.Partial("QsdRenders/QsdBody", new QsdRenderModel()
                   {
                       AllSubItems = Model.QizSessionDetails.Where(v => string.IsNullOrEmpty(v.QizSubjectDefine.ParentSubjDefID)).OrderBy(v => v.QizSubjectDefine.SortIdx),
                       CurrentDeepLvl = 0,
                       ParentID = "root",
                       CurrentItem = null
                   })
                    </td>
                </tr>
            </table>
            @{
    bool b = Model.UserID == Guid.Empty || Model.UserID == SiteUser.UserId ||
            Model.QizSubject.QizSubjectObjForDoctors.Any(t => t.DoctorID == SiteUser.UserId) ||
            (SiteUser.IsDoctorDepManager && Model.QizSubject.DepID == SiteUser.DepartmentID);
            }
            <p style="@(!PreviewOnly && b ? "" : "display:none")">
                @if (!PreviewOnly && b)
                {
                    <input type="submit" value="提交" onclick="var r= confirm('请确认是否提交随访内容，提交后的随访将无法修改。\r\n\r\n建议您一定要对填写的内容作充足的检查以避免收到不正确的诊断提示。\r\n\r\n请问是否提交？');if(r)$(this).hide();return r;" />
                }
                else
                { 
                    <input type="submit" value="提交" disabled="disabled" />
                }
            </p>
        </fieldset>
    </div>
}
@Html.Partial("QsdRenders/SubQsds",Model)
@if (SiteUser.IsDoctorDepManager && Model.QizSubject.DepID == SiteUser.DepartmentID)
{
    var tagvs = "'" + string.Join("','", SiteUser.Department.DepartmentProfiles.Where(v => v.SettingKey == "TianBaoZhiLiang").Select(v => v.SettingValue).Distinct().ToArray()) + "'";
    //SiteUser.Department.DepartmentProfiles.Where(v => v.SettingKey == "SuiFangLeiXing").Select(v => v.SettingValue).Distinct().ToArray();   
    //var sflxs = "'" + string.Join("','", SiteUser.Department.QizSubjects.Where(v => v.StatusID == "100" && v.SubjectType != "指标库").Select(v => v.Title).Distinct().ToArray()) + "'";
    

    using (Ajax.BeginForm("TianBaoZhiLiangEdit", new AjaxOptions()
    {
        LoadingElementId = "OnLoadingSpan",
        UpdateTargetId = "",
        InsertionMode = InsertionMode.Replace,
        HttpMethod = "Post",
        OnSuccess = "alert('操作成功。')",
        OnFailure = "OnSiteError"
    }))
    {
    <span class="normal-input">填报质量评价：
        @Html.Hidden("SessionID", Model.ID)
        @*@Helpers.RadioList("TianBaoZhiLiang", "重复,其他,无效,未处理,填写".Split(','), "重复,其他,无效,未处理,填写:".Split(','), 4, true)*@
        @*@Html.TextBox("TianBaoZhiLiang_Other", Model.TianBaoZhiLiang)</span>*@
        @Html.TextBox("TianBaoZhiLiang", Model.TianBaoZhiLiang)</span>
    <input type="submit" value="提交" />
    <script type="text/javascript">
        $(function () {
            $("#TianBaoZhiLiang").select2({ tags: [ @Html.Raw(tagvs)] });
        });
    </script>
    }
}
<script type="text/javascript">
    $(function () {
        $('input:submit').button({
            icons: {
                primary: "ui-icon-locked"
            }
        });
    });
</script>
@if (!PreviewOnly)
{
    <script type="text/javascript">
        $(function () {
            $("#SessionForm :radio").change(function () {
                $(this).closest("li.quiz-item-body").find("ul").hide("swing");
                $(this).closest("li.quiz-item-body").find("ul").find('input,select').prop("disabled", true);
                $(this).closest("li.quiz-item-body").find("ul#" + $(this).attr("selitemsubid")).show("swing");
                $(this).closest("li.quiz-item-body").find("ul#" + $(this).attr("selitemsubid")).find('input,select').prop("disabled", false);
            });

            $("#SessionForm :radio:checked").each(function () { $(this).closest("li.quiz-item-body").find("ul#" + $(this).attr("selitemsubid")).show("swing"); })

        });


    </script>
}
else
{ 
    <script type="text/javascript">
        $("#SessionForm input").attr("disabled", true);
        $("#SessionForm select").attr("disabled", true);

        $(function () {
            $("#SessionForm input").attr("disabled", true);
            $("#SessionForm select").attr("disabled", true);
            $("#SessionForm :radio:checked").each(function () { $(this).closest("li.quiz-item-body").find("ul#" + $(this).attr("selitemsubid")).show("swing"); })

        });

    </script>
}
